package com.example.movie.ui.movie.adapter

import android.content.Context
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.example.movie.R
import com.example.movie.ui.movie.fragment.BlankFragment
import com.example.movie.ui.movie.fragment.CommentFragment

private val TAB_TITLES = arrayOf(
    R.string.movie_comment,
    R.string.movie_detail,
    R.string.movie_recommend
)

class MovieDetailBottomPagerAdapter(private val context: Context, fm: FragmentManager) :
    FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

    override fun getItem(position: Int): Fragment {
        when(position){
            0 ->{
                return CommentFragment()
            }
            else -> return BlankFragment()
        }
    }

    override fun getPageTitle(position: Int): CharSequence {
        return context.resources.getString(TAB_TITLES[position])
    }

    override fun getCount() = TAB_TITLES.size
}